﻿using System;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using Microsoft.Extensions.Logging;

namespace RotovapPlatform.UI.ViewModels.ExperimentManagement
{
	/// <summary>
	/// 实时过程数据视图模型
	/// </summary>
	public partial class RealTimeDataViewModel : ObservableObject
	{
		private readonly ILogger<RealTimeDataViewModel> _logger;

		/// <summary>
		/// 温度数据集合
		/// </summary>
		[ObservableProperty]
		private ObservableCollection<double> _temperatureData = new ObservableCollection<double>();

		/// <summary>
		/// 压力数据集合
		/// </summary>
		[ObservableProperty]
		private ObservableCollection<double> _pressureData = new ObservableCollection<double>();

		/// <summary>
		/// 旋转速度数据集合
		/// </summary>
		[ObservableProperty]
		private ObservableCollection<double> _rotationSpeedData = new ObservableCollection<double>();



		/// <summary>
		/// 构造函数
		/// </summary>
		/// <param name="logger">日志记录器</param>
		public RealTimeDataViewModel(ILogger<RealTimeDataViewModel> logger)
		{
			_logger = logger;
			_logger.LogInformation("实时过程数据视图模型已初始化");
		}

		/// <summary>
		/// 初始化
		/// </summary>
		public async Task InitializeAsync()
		{
			try
			{
				
				_logger.LogInformation("正在初始化实时过程数据...");

				// 这里将来会添加实际的数据加载逻辑
				await Task.Delay(500); // 模拟加载延迟

				_logger.LogInformation("实时过程数据初始化完成");
			}
			catch (Exception ex)
			{
				_logger.LogError(ex, "初始化实时过程数据时发生错误");
			}
			finally
			{
				
			}
		}
	}
}